package com.lcl.jarvis.admin.modules.person.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.lcl.jarvis.admin.modules.person.dto.request.TbPersonInfoDPageReqDTO;
import com.lcl.jarvis.admin.modules.person.dto.request.TbPersonInfoDReqDTO;
import com.lcl.jarvis.admin.modules.person.dto.response.TbPersonInfoDRespDTO;
import com.lcl.jarvis.admin.modules.person.service.ITbPersonInfoDService;
import lombok.RequiredArgsConstructor;
import com.lcl.jarvis.common.model.R;
import com.lcl.jarvis.common.model.PageResult;

/**
 * 数据筛查管理Controller
 *
 * @author licl
 * @date 2024-06-21 16:30:49
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/person/Person")
public class TbPersonInfoDController {

    private final ITbPersonInfoDService tbPersonInfoDService;

    /**
     * 新增数据筛查管理
     *
     * @param body
     * @return
     */
    @PreAuthorize("hasAuthority('person:Person:add')")
    @PostMapping
    public R<Integer> add(@RequestBody TbPersonInfoDReqDTO body) {
        return R.succeed(tbPersonInfoDService.add(body));
    }

    /**
     * 删除数据筛查管理
     *
     * @param ids
     * @return
     */
    @PreAuthorize("hasAuthority('person:Person:remove')")
    @DeleteMapping("/{ids}")
    public R<Integer> remove(@PathVariable List<String> ids) {
        return R.succeed(tbPersonInfoDService.remove(ids));
    }

    /**
     * 修改数据筛查管理
     *
     * @param body
     * @return
     */
    @PreAuthorize("hasAuthority('person:Person:edit')")
    @PutMapping
    public R<Integer> update(@RequestBody TbPersonInfoDReqDTO body) {
        return R.succeed(tbPersonInfoDService.update(body));
    }

    /**
     * 获取数据筛查管理详细信息
     *
     * @param id
     * @return
     */
    @PreAuthorize("hasAuthority('person:Person:query')")
    @GetMapping(value = "/{id}")
    public R<TbPersonInfoDRespDTO> detail(@PathVariable("id") String id) {
        return R.succeed(tbPersonInfoDService.detail(id));
    }

    /**
     * 查询数据筛查管理列表
     *
     * @param req
     * @return
     */
    @PreAuthorize("hasAuthority('person:Person:list')")
    @GetMapping("/list")
    public R<PageResult<TbPersonInfoDRespDTO>> page(TbPersonInfoDPageReqDTO req) {
        return R.succeed(tbPersonInfoDService.page(req));
    }

}
